<template>
  <div id="sale">  
    <div  style="display:flex;align-items: center;margin-bottom:10px;">
          <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
          <div style="line-height: 40px;font-weight:bold:">解冻申请</div>
    </div> 

 <el-form ref="form" :model="form" label-width="80px">  
     <el-row>   

        <el-col :span="12" style="display:flex;">

           <el-form-item label-width="0px" style="">
                <el-select  v-model="form.select_num" placeholder="请选择状态"  @change="select_change" style="width:160px;">
                    <el-option  v-for="(item,index) in select_data" :key="index" :label="item.name" :value="item.id" ></el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="" label-width="0px" style="margin-left:10px;">
                 <el-date-picker type="date"  placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="form.time"  style="width:160px;"></el-date-picker>
            </el-form-item>


          <el-form-item label-width="0px" style="margin-left:10px;">
            <el-input v-model="form.account" placeholder="姓名/手机号" class="search" style="width:160px;"></el-input>
          </el-form-item>

           <div class="custom_button"  @click="search_but"></div>
        </el-col>
 
       
    </el-row>
    
    <el-row>
        <el-col :span="24" style="text-align: right;">    
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk1_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />信用比例
            </el-button>        
        </el-col>
     </el-row>

   </el-form>

   <!-- 渲染数据list -->
   <aftersale-list :saledata="saledata" @up_list_fun="list_fun"> </aftersale-list>

      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>


     <!-- 信用比例 -->
    <el-dialog title="信用比例" :visible.sync="mtk1"  width="400px">
        <div style="width:100%;"> 

           <el-form ref="form"   label-width="70px" style="width:100%;">     
                 <el-form-item label="信用比例">
                        <el-input    v-model="mtk1_form.number" placeholder="信用比例"></el-input>
                </el-form-item>
            </el-form>
            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk1_qr_but()">确认</el-button>
            </div>

        </div> 
    </el-dialog>

    

      
  </div>
</template>

<script>
import AftersaleList from '@/view/Aftersale/AftersaleList'
export default {
  name: 'sale',
  data () {
    return {
        saledata:[],
        page:1,
        count:0,
        form:{
           account:'',
           select_num:0,
           time:'',
        },
        select_data:[{'id':0,"name":'全部'},{'id':1,"name":'待审核'},{'id':2,"name":'同意'},{'id':3,"name":'拒绝'}],
        mtk1:false,
        mtk1_form:{
          number:''
        }
    }
  },
 components:{
    AftersaleList
  },
  created(){
     this.list_fun()
  },
  mounted (){
    
  },
  methods: {
      list_fun(){
          this.post("/thaw_apply/listOfData", {
              page:this.page,
              account:this.form.account,
              onedate:this.form.time,
              type:this.form.select_num
	        }).then(res => {
            this.count = res.result.count
            this.saledata = res.result.list
            for(let item of this.saledata) {
               
                item.voucher_linkList = [this.urlimg + item.voucher_link]  //冻结凭证

              }
            console.log(res)
         })
      },
      mtk1_but(){
        this.mtk1_fun()
         this.mtk1 = true
      },
      mtk1_fun(){
           this.post("/thaw_apply/exchangeScale", {
	        }).then(res => {
             this.mtk1_form.number = res.result.scale
             //console.log(res)
         })
      },
      mtk1_qr_but(){
        
         this.post("/thaw_apply/setExchangeScale", {
                   scale:this.mtk1_form.number
                }).then(res => {

                    if(res.error_code == 0){
                      this.open1(res.result,'success')  //提示框
                      this.mtk1_fun()
                      this.mtk1 = false
                    }else {
                    this.open1(res.message,'warning')
                }

        })

      },
      select_change(){
         this.page = 1
         this.list_fun()
     },
     search_but(){
          this.page = 1
         this.list_fun()
     },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>
</style>
